package com.shop.cereshop.commons.tencent.im.enums.notice;

import com.shop.cereshop.commons.tencent.im.model.dto.SysNoticeTypeDTO;
import lombok.Getter;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @description: 系统通知类型枚举
 * @author zdd
 * @date 2025/9/15 11:27
 * @version 1.0
 */
@Getter
public enum SysNoticeTypeEnum {

    COMMENT(1, "comment", "评论"),
    REPLY(2, "reply", "回复"),
    LIKE(3, "like", "点赞"),
    CANCEL_LIKE(4, "cancel_like", "取消点赞"),
    COLLECT(5, "collect", "收藏"),
    CANCEL_COLLECT(6, "cancel_collect", "取消收藏"),
    FOLLOW(7, "follow", "关注"),
    CANCEL_FOLLOW(8, "cancel_follow", "取消关注"),
    REWARD(9, "reward", "打赏"),
    SHARE(10, "share", "分享"),

    SYSTEM_BULLETIN(21, "system_bulletin", "系统公告"),
    PLATFORM_CONSULTATION(22, "platform_consultation", "平台咨询"),

    ;

    private final Integer code;
    private final String name;
    private final String msg;

    private static final Map<Integer, SysNoticeTypeEnum> CODE_MAP =
            Arrays.stream(values()).collect(Collectors.toMap(SysNoticeTypeEnum::getCode, e -> e));

    public static final List<SysNoticeTypeDTO> SYS_NOTICE_TYPE_LIST =
            Collections.unmodifiableList(
                    Arrays.stream(values())
                            .map(enumValue -> new SysNoticeTypeDTO(
                                    enumValue.getCode(),
                                    enumValue.getName(),
                                    enumValue.getMsg()
                            ))
                            .collect(Collectors.toList())
            );

    SysNoticeTypeEnum(Integer code, String name, String msg) {
        this.code = code;
        this.name = name;
        this.msg = msg;
    }

    public static String getNameByCode(Integer code) {
        SysNoticeTypeEnum typeEnum = CODE_MAP.get(code);
        return typeEnum != null ? typeEnum.getName() : "";
    }

    public static String getMsgByCode(Integer code) {
        SysNoticeTypeEnum typeEnum = CODE_MAP.get(code);
        return typeEnum != null ? typeEnum.getMsg() : "";
    }
}
